//
//  ViewController.m
//  CollectionViewTest
//
//  Created by dllo on 16/6/12.
//  Copyright © 2016年 doll. All rights reserved.
//

#import "ViewController.h"
#import "CollectionViewCell.h"

@interface ViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>

@end

@implementation ViewController
- (void)dealloc{
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self creatCollectionView];
}

- (void)creatCollectionView{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.itemSize = CGSizeMake(150, 200);
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20);
    layout.minimumInteritemSpacing = 10;
    layout.minimumLineSpacing = 10;
    
    UICollectionView *cView = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:layout];
    cView.backgroundColor = [UIColor orangeColor];
    cView.delegate = self;
    cView.dataSource = self;
    
    [cView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"collectionViewCell"];
    [self.view addSubview:cView];
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectionViewCell" forIndexPath:indexPath];
    cell.backgroundColor = [UIColor redColor];
    return cell;
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
